﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.Security;

namespace NJL.WebUsers.AdminVisitor
{
    public partial class ChangePassword :BasePage
    {
        NJL.BLL.NJL_USER bllUser = new BLL.NJL_USER();
        NJL.Model.NJL_USER modelUser;
        protected void Page_Load(object sender, EventArgs e)
        {
           
        }
        protected void btnSumbit_Click(object sender, EventArgs e)
        {
            string oldPwd = FormsAuthentication.HashPasswordForStoringInConfigFile(txtFirsthandPwd.Text.Trim(), "MD5");
         
            modelUser = bllUser.GetModel(UserId);
            if (modelUser.USER_PASSWORD_MD5 != oldPwd)
            {
                Royalsoft.Common.MessageBox.Show(this, "您输入的原始密码不正确，请重新输入");
                return;
            }
            modelUser.USER_PASSWORD = txtNewPwd.Text.Trim();
            modelUser.USER_PASSWORD_MD5 = hidPwd.Value;
            if (bllUser.Update(modelUser))
            {
                Royalsoft.Common.MessageBox.Show(this, "密码修改成功");
            }
        }
    }
}